package cn.edu.sgu.www.mhxysy.service.except.impl;

import cn.edu.sgu.www.mhxysy.entity.except.Property;
import cn.edu.sgu.www.mhxysy.mapper.except.PropertyMapper;
import cn.edu.sgu.www.mhxysy.service.except.PropertyService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 沐雨橙风ιε
 * @version 1.0
 */
@Service
public class PropertyServiceImpl implements PropertyService {

    private final PropertyMapper propertyMapper;

    @Autowired
    public PropertyServiceImpl(PropertyMapper propertyMapper) {
        this.propertyMapper = propertyMapper;
    }

    @Override
    public List<Property> selectAll() {
        return propertyMapper.selectList(null);
    }

    @Override
    public Property selectById(Integer id) {
        return propertyMapper.selectById(id);
    }

    @Override
    public List<Property> selectByType(Integer type) {
        QueryWrapper<Property> queryWrapper = new QueryWrapper<>();

        queryWrapper.eq("type", type);

        return propertyMapper.selectList(queryWrapper);
    }

}